<?php

class Blog {
	
	public $id;
	public $artikli;
	
	// constructor
	
	public function __construct($i = 0) {
		$this->id = $i;
	}
	
	// functions
	
	public function getArticles() {
		$q = "SELECT id FROM vest ORDER BY vazna DESC, prioritet DESC, datum DESC";
		$r = mysql_query("set names 'utf8'");
		$r = mysql_query($q);
		if (!mysql_num_rows($r)) throw new Exception("Jos uvek nije napisan nijedan clanak!");
		while ($n = mysql_fetch_array($r)) {
			$this->artikli[] = new Article($n['id']);
		}
	}
	
	public function getLatestNews() {
		$q = "SELECT id FROM vest ORDER BY vazna DESC, prioritet DESC, datum DESC LIMIT 0,3";
		$r = mysql_query("set names 'utf8'");
		$r = mysql_query($q);
		if (mysql_num_rows($r))
		while ($n = mysql_fetch_array($r)) {
			$this->artikli[] = new Article($n['id']);
		}
	}
	
} // end of class Blog


?>